package com.example.m2;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Scanner;


@Component
public class Producer {
    @Autowired

    AmqpTemplate t;//

    public void send() {
        // 转换并发送
        while (true){
            System.out.println("输入消息：");
            String s = new Scanner(System.in).nextLine();
            System.out.println("消息已发送");
            t.convertAndSend("task_queue", s);//两个消费者公用一个消息队列


        }

    }


}
